﻿using System;
using System.Web.Security;
using SmartHRMS.Model.Account;
using StructureMap;

namespace SmartHRMS.UI.Web.Controls
{
    public partial class SiteHeader : System.Web.UI.UserControl
    {
        private IPrincipalService _ICustomPrincipalService = ObjectFactory.GetInstance<IPrincipalService>();

        protected void Page_Load(object sender, EventArgs e)
        {
            // Put user code to initialize the page here
            Greeting.Text = "Welcome to Smart Human Resource Management System [no version yet], ";
            if (_ICustomPrincipalService.Identity.IsAuthenticated)
            {
                Greeting.Text += "<b>" +_ICustomPrincipalService.Identity.Name + "</b>";
                UserLink.Text = "My Account";
                UserLink.NavigateUrl = "/SmartHRMS/Administration/Memebership/UserDetailPage.aspx";
                SignOut.Visible = true;
            }
            else
            {
                Greeting.Text += "Guest User.";
                UserLink.Text = "Sign In";
                UserLink.NavigateUrl = "~/LoginPage.aspx";
                SignOut.Visible = false;
            }		
        }

        protected void SignOut_Click(object sender, EventArgs e)
        {
            this.Session.Clear();
            FormsAuthentication.SignOut();
            Response.Redirect("~/DefaultPage.aspx");
        }


    }
}